package com.zhouzhou.fastjava.util;

import java.math.BigDecimal;

public abstract class BigDecimalKit {

    private BigDecimalKit() {
    }

    /**
     * ==
     */
    public static boolean equals(BigDecimal left, BigDecimal right) {
        return left.equals(right);
    }

    /**
     * !=
     */
    public static boolean notEquals(BigDecimal left, BigDecimal right) {
        return !equals(left, right);
    }

    /**
     * >
     */
    public static boolean gt(BigDecimal left, BigDecimal right) {
        return left.compareTo(right) > 0;
    }

    /**
     * >=
     */
    public static boolean ge(BigDecimal left, BigDecimal right) {
        return left.compareTo(right) >= 0;
    }

    /**
     * >
     */
    public static boolean gt(BigDecimal left, int right) {
        return left.compareTo(new BigDecimal(right)) > 0;
    }

    /**
     * >=
     */
    public static boolean ge(BigDecimal left, int right) {
        return left.compareTo(new BigDecimal(right)) >= 0;
    }

    /**
     * <
     */
    public static boolean lt(BigDecimal left, BigDecimal right) {
        return !ge(left, right);
    }

    /**
     * <=
     */
    public static boolean le(BigDecimal left, BigDecimal right) {
        return !gt(left, right);
    }

    /**
     * <
     */
    public static boolean lt(BigDecimal left, int right) {
        return !ge(left, right);
    }

    /**
     * <=
     */
    public static boolean le(BigDecimal left, int right) {
        return !gt(left, right);
    }

    /**
     * /
     */
    public static BigDecimal divide(BigDecimal numerator, BigDecimal denominator) {
        return numerator.divide(denominator, 2, BigDecimal.ROUND_HALF_UP);
    }

    /**
     * of
     */
    public static BigDecimal of(Integer value) {
        return new BigDecimal(value);
    }

    /**
     * of
     */
    public static BigDecimal of(String value) {
        return new BigDecimal(value);
    }

    /**
     * of
     */
    public static BigDecimal of(double value) {
        return BigDecimal.valueOf(value);
    }

}
